

$(document).ready(function(){
  $("#wpcf7-f149-t1-o1 form").attr("id","form-contatti");
  formscript("form-contatti");
  
  
});


function Dialog(str){
  var url = getBaseURL();
  $.blockUI.defaults.css = {};
  $.blockUI({
    css: {
      "top":"5%",
      "left":"25%",
      "cursor":"normal"
    },
    message:"<div id='bg-message'><div id='modal-close' title='Chiudi'></div>"+str+"</div>",
    onBlock:function(){
      $("#modal-close").css({
        "background":"url('"+url+"wp-content/themes/PontediCarta/img/modal-close.png') 0 0 transparent",
        "width":"30px",
        "height":"30px",
        "cursor":"pointer",
        "position":"absolute",
        "top":"-10px",
        "left":"610px"
      });
      $("#modal-close").mouseenter(function(){
        $(this).css({
          "background-position":" 0 -30px"
        });
      });
      $("#modal-close").mouseleave(function(){
        $(this).css({
          "background-position":" 0 0"
        });
      });
      $("#modal-close").click(function(){
        $(".blockOverlay").trigger("click");
      })
      $("#bg-message").css({
        "background-color": "#96414D",
        "padding": "40px 150px",
        "color": "white",
        "-webkit-border-radius": "5px",
        "-moz-border-radius": "5px"
      });
      $('#modal-cphiudi').attr('title','Clicca per sbloccare').click(function(evt){
        evt.preventDefault();
        $.unblockUI();
      });
      $('.blockOverlay').click(function(){
        $.unblockUI();
      });
    }
  });
} 

function centerElement(element){
  var perc = parseInt((100*$(element).width())/$(document).width());
  perc = 100-perc;
  var left = 0;
  if(perc > 0) left=parseInt(perc/2);
  else left = 0;
  $(element).css({
    "left":left+"%"
  });
  $(window).resize(function(){
    var perc = parseInt((100*$(element).width())/$(document).width());
    perc = 100-perc;
    var left =0;
    if(perc > 0) left=parseInt(perc/2);
    else left = 0;
    $(element).css({
      "left":left+"%"
                                
    });
    return;
  });
}

function getBaseURL() {
  var url = location.href;  // entire url including querystring - also: window.location.href;
  var baseURL = url.substring(0, url.indexOf('/', 14));


  if (baseURL.indexOf('http://localhost') != -1) {
    // Base Url for localhost
    var url = location.href;  // window.location.href;
    var pathname = location.pathname;  // window.location.pathname;
    var index1 = url.indexOf(pathname);
    var index2 = url.indexOf("/", index1 + 1);
    var baseLocalUrl = url.substr(0, index2);

    return baseLocalUrl + "/";
  }
  else {
    // Root Url for domain name
    return baseURL + "/";
  }

}

$(document).ready(function(){
  $(".torna-su").click(function(ev){
    ev.preventDefault();
    $("html,body").animate({
      "scrollTop":"0"
    },1000);
  })
});


//seiqui
$(document).ready(function(){
  $(".current").click(function(evt){
   evt.preventDefault(); 
    });
  $("#menu .current").attr("title","Sei nella "+$(".current").attr("title"));
  $("#menu a:not(.current)").each(function(){
    var elem = this;
    $(elem).attr("title","Vai alla "+$(elem).attr("title"));
  });
    
});